package com.marmot.cloud.framework.biz.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.marmot.cloud.framework.orm.jpa.comment.annotation.Comment;
import com.marmot.cloud.framework.orm.jpa.entity.BaseTenantJpaEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper=false)
@Accessors(chain = true)
@Entity
@Table(name = "t_user")
@EntityListeners(AuditingEntityListener.class)
@Comment("用户信息表")
public class User extends BaseTenantJpaEntity {

    @Column(length = 30)
    @Comment("登录账号")
    private String loginName;

    @Column(length = 50)
    @Comment("密码")
    private String loginPwd;

    @Column(length = 30)
    @Comment("用户昵称")
    private String userName;

    @Column
    @Comment("用户类型: 1=系统用户, 2=普通用户")
    private Integer userType;

    @Column(length = 50)
    @Comment("用户邮箱")
    private String email;

    @Column(length = 20)
    @Comment("固定电话")
    private String phone;

    @Column(length = 11)
    @Comment("手机号码")
    private String mobile;

    @Column
    @Comment("用户性别: 1=男, 2=女, 3=未知")
    private Integer sex;

    @Column(length = 100)
    @Comment("头像路径")
    private String avatar;

    @Column(length = 20)
    @Comment("盐加密")
    private String salt;

    @Column(columnDefinition = "int default 1")
    @Comment("帐号状态: 1=正常, 2=禁用")
    private Integer status;

    @Column(length = 32)
    @Comment("所属部门ID")
    private String deptId;

    @Column(length = 50)
    @Comment("最后登陆IP")
    private String loginIp;

    @Column
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Comment("最后登陆时间")
    private LocalDateTime loginDate;

}

